extends ../main

block append body
    div#commision.panel.box-shadow-none.content-header
        div.panel-body
            div.col-md-12
                h3.animated.fadeInLeft 用户管理
                p.animated.fadeInDown
                    | 用户管理&nbsp;
                    span.fa-angle-right.fa
                        | &nbsp;佣金管理
    div.col-md-12.top-20.padding-0
        div.col-md-12
            div.panel
                div.panel-body
                    div#toolbar.btn-group
                        button#btn_add.btn.btn-default(type="button")
                            span.glyphicon.glyphicon-plus(aria-hidden="true")
                               |修改佣金比例
                    table#tb_departments
    //--模态框--//
    div#myModal.modal.fade(tabindex="-1",role="dialog",aria-labelledby="myModalLabel",aria-hidden="true")
        div.modal-dialog(style="width: 500px;height: 100px;")
            div.modal-content
                div.modal-header
                    button.close(type="button",data-dismiss="modal",aria-hidden="true") ×
                    h4#myModalLabel.modal-title 修改佣金比例
                div.modal-body
                    div.form-horizontal
                        div.form-group
                            label.col-sm-3.control-label(for="level1") 一级比例(%)
                            div.col-sm-5
                                input#level1.form-control(type="text",placeholder="一级比例")
                        div.form-group
                            label.col-sm-3.control-label(for="level2") 二级比例(%)
                            div.col-sm-5
                                input#level2.form-control(type="text",placeholder="二级比例")
                div.modal-footer
                    button.btn.btn-default(type="button",data-dismiss="modal") 关闭
                    button#submit.btn.btn-primary(type="button") 提交更改


block append footer
    script(type="text/javascript").
        $(function () {
            var app = new Vue({
                el: "#commision",
                data: {},
                methods:{
                    init: function () {
                        var columns = [{
                            checkbox: 'ture'
                        }, {
                            field: 'userName',
                            width: '15%',
                            title: '用户姓名'
                        }, {
                            field: 'prodName',
                            width: '17%',
                            title: '商品名称'
                        }, {
                            field: 'prodspec',
                            width: '15%',
                            title: '商品规格'
                        }, {
                            field: 'ordId',
                            width: '10%',
                            title: '订单编号'
                        }, {
                            field: 'prodSum',
                            width: '10%',
                            title: '购买数量'
                        }, {
                            field: 'prodPrice',
                            width: '10%',
                            title: '商品单价',
                            formatter: function (value, row, index) {
                                return value / 100 + '元';
                            }
                        },{
                            field: 'orderStatus',
                            width: '10%',
                            title: '订单状态',
                            formatter: function (value, row, index) {
                                switch (value) {
                                    case "1":
                                        return "购物车";
                                        break;
                                    case "2":
                                        return "待付款";
                                        break;
                                    case "3":
                                        return "待发货";
                                        break;
                                    case "4":
                                        return "已发货";
                                        break;
                                    case "5":
                                        return "已完成";
                                        break;
                                    case "9":
                                        return "已取消";
                                        break;
                                    default:
                                        return "-";
                                        break;
                                }
                            }
                        },{
                            field: 'createTime',
                            width:'10%',
                            title: '创建时间',
                            formatter: function (value, row, index) {
                                var date = new Date(value);
                                return date.getUTCFullYear() + '-' + (date.getUTCMonth() + 1) + '-' + date.getUTCDate() + ' ' + date.getHours() + ':' + date.getMinutes() + ':' + date.getSeconds()
                            }

                        }];
                        var tableInit = zxlib.datatable("tb_departments", "tb_id", "/manager/customer/getcommision", columns);
                        console.log(tableInit);
                        tableInit.init();

                        var oButtonInit = new ButtonInit();
                        oButtonInit.Init();

                    }

                }

            });

            app.init();
        });



        var ButtonInit = function () {
            var oInit = new Object();
            var postdata = {};

            oInit.Init = function () {
                $('#btn_add').click(function () {
                    $.get('${basePath}/getLevels', null, function (data) {
                        for (var i in data) {
                            if (data[i].LEVEL1) {
                                $('#level1').val(data[i].LEVEL1);
                            }
                            if (data[i].LEVEL2) {
                                $('#level2').val(data[i].LEVEL2);
                            }
                        }
                    });
                    $('#myModal').modal('show');
                });
            };

            return oInit;
        };
